'''
Created on Feb 29, 2012

@author: Johnathon
'''
import unittest
from Wire import Wire
from LineValues import X, D, DNot, One, Zero
import util

class TestWire(unittest.TestCase):

    def test_propagateDrive(self):
        wire1 = Wire("1", 0, None, [])
        wire2  = Wire("2", 0, wire1, [])
        wire3 = Wire("3", 0, wire1, [])
        wire1.destinations.append(wire2)
        wire1.destinations.append(wire3)
        for value in util.VALUES: 
            wire1.driveValue(value)
            self.assertTrue(wire1.value is value, "wire1 failed on %s" % (value))
            self.assertTrue(wire2.value is value, "wire2 failed on %s" % (value))
            self.assertTrue(wire3.value is value, "wire3 failed on %s" % (value))

    def test_driveX(self):
        wire = Wire("Lol", 0, None, ())
        wire.driveValue(X)
        self.assertTrue(wire.value is X)

    def test_driveD(self):
        wire = Wire("Lol", 0, None, ())
        wire.driveValue(D)
        self.assertTrue(wire.value is D)
        
    def test_driveDNot(self):
        wire = Wire("Lol", 0, None, ())
        wire.driveValue(DNot)
        self.assertTrue(wire.value is DNot)

    def test_drive1(self):
        wire = Wire("Lol", 0, None, ())
        wire.driveValue(One)
        self.assertTrue(wire.value is One)
        
    def test_drive0(self):
        wire = Wire("Lol", 0, None, ())
        wire.driveValue(Zero)
        self.assertTrue(wire.value is Zero)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()